﻿@model MasResourceSubGroup

@{
    int resGrpId = ViewBag.ResGrpId;
    var resGrp = new KPIS.GERP.WEB.GIMS.MasResourceService.MasResourceServiceClient().SelectResourceGroup(new MasResourceGroup{ResGrpId = resGrpId},null).FirstOrDefault();
    var resType = new KPIS.GERP.WEB.GIMS.MasResourceService.MasResourceServiceClient().SelectResourceType(new MasResourceType{ResTypeId = resGrp.ResTypeId.Value}, null).FirstOrDefault();
    ViewBag.CustomMenu = new Dictionary<string, string>
        {
            {
                "ประเภท" + resType.Name, Url.Action("Index", "MasResourceType")
            }, 
            {
                "หมวด" + resGrp.Name, Url.Action("Index", "MasResourceGroup", new {resTypeId=resGrp.ResTypeId})
            }, 
            {
                "กลุ่ม", Url.Action("Index", "MasResourceSubGroup", new {resGrpId = resGrp.ResGrpId})
            }
        };
    ViewBag.ResGrp = resGrp;
    ViewBag.Title = "สร้างกลุ่มพัสดุ";
    ViewBag.Descr = "เพิ่มข้อมูลกลุ่มพัสดุ";
}

@using (Html.BeginForm("Create", "MasResourceSubGroup", FormMethod.Post, new { @class = "form-horizontal", ViewBag.ResGrpId }))
{
     @Html.AntiForgeryToken() 

    <div class="block-button-menu-above">
        @Html.ButtonViewAll(new {ViewBag.ResGrpId})
        @Html.ButtonSubmit()
    </div>
    
    @Html.Partial("_EditorForm")
    @Html.ValidationSummary(true, ValidateText.RequiredField, new { @class = "alert alert-error" })
}

@section scripts
{
    <script>
        $("form").not("#formsearch").submit(function (e) {
            e.preventDefault();
            var currentForm = this;
            bootbox.confirm("ท่านต้องการยืนยัน ใช่หรือไม่", function (result) {
                if (result) {
                    currentForm.submit();
                }
            });
        });
    </script>
}